﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;
using System.Collections;

using XJX.DataLayer;

namespace XJX.BusinessLayer
{
    public class Listening
    {
        private string ConnToData;

        public Listening(string newConnectionString)
        {
            ConnToData = newConnectionString;
        }

        public bool LB_Add_New_ListeningBook_Info
            (
            string Title,
            string Description,
            string AnnouncerInfo,
            string FileInfo,
            string TimeLength,
            string BookLinkPic,
            string BookLinkInfo,
            out int ReturnValue,          //返回参数值
            out string ReturnFieldValue   //返回字段值,返回插入的新值ID编号
            )
        {
            bool b;

            try
            {
                b = new XJX.DataLayer.Listening(ConnToData).LB_Add_New_ListeningBook_Info(Title,Description, AnnouncerInfo,FileInfo,TimeLength, BookLinkPic, BookLinkInfo, out ReturnValue, out ReturnFieldValue);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }

        public bool LB_Del_One_ListeningBook_From_LBID(string LBID)
        {
            bool b;

            try
            {
                b = new XJX.DataLayer.Listening(ConnToData).LB_Del_One_ListeningBook_From_LBID(LBID);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }

        public bool LB_Modify_One_ListeningBook_Info
            (
            string LBID,
            string Title,
            string Description,
            string AnnouncerInfo,
            string FileInfo,
            string TimeLength,
            string BookLinkPic,
            string BookLinkInfo
            )
        {
            bool b;

            try
            {
                b = new XJX.DataLayer.Listening(ConnToData).LB_Modify_One_ListeningBook_Info(LBID, Title, Description,AnnouncerInfo,FileInfo,TimeLength,BookLinkPic, BookLinkInfo);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }

        //得到一个节目内容
        public Hashtable Get_One_ListeningBook_Info_From_LBID(string LBID)
        {
            Hashtable ht = new Hashtable();
            DataTable dt = new DataTable();

            DataSet ds = new XJX.DataLayer.Listening(ConnToData).Get_One_ListeningBook_Info_From_LBID(LBID);
            dt = ds.Tables[0];

            ArrayList data = Common.DataTable2ArrayList(dt);

            ht["rows"] = data;

            return ht;
        }


        //一般浏览用户或者管理员获取交流主题的标题列表
        public Hashtable LB_Search_ListeningBook_List
            (
            string Title,
            string IsAll,

            int PageIndex,
            int PageSize
            )
        {
            Hashtable ht = new Hashtable();
            DataTable dt = new DataTable();
            int PageCount = 0;
            int TotalCount = 0;


            DataSet ds = new XJX.DataLayer.Listening(ConnToData).LB_Search_ListeningBook_List
                    (Title, IsAll, PageIndex, PageSize, out PageCount, out TotalCount);
            dt = ds.Tables[0];

            ArrayList data = Common.DataTable2ArrayList(dt);

            ht["PageCount"] = PageCount;//页数,将在哈希表中输出成字符串。
            ht["RecordCount"] = TotalCount;//记录总数
            ht["rows"] = data;

            return ht;
        }

        //屏蔽或显示一条
        public bool LB_ShieldORDisp_One_ListeningBook_By_LBID
        (
            string LBID,
            out int ReturnValue,
            out string ReturnFieldValue
            )
        {
            bool b;

            try
            {
                b = new XJX.DataLayer.Listening(ConnToData).LB_ShieldORDisp_One_ListeningBook_By_LBID(LBID, out ReturnValue, out ReturnFieldValue);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }


        //置顶一条
        public bool LB_StickORCannel_One_ListeningBook_By_LBID
        (
            string LBID,
            out int ReturnValue,
            out string ReturnFieldValue
            )
        {
            bool b;

            try
            {
                b = new XJX.DataLayer.Exchange(ConnToData).StickORCannel_One_ExchangeTheme_By_EXID(LBID, out ReturnValue, out ReturnFieldValue);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }
    }
}
